package com.scott.ch02.student.client;

import com.scott.ch02.spring.SpringConfiguration;
import com.scott.ch02.student.bean.StudentBean;
import com.scott.ch02.student.service.StudentService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.UUID;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-11-23 22:22:24
 */
public class StudentDaoTest {


    @Test
    public void addTest(){
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfiguration.class);
        String[] names = context.getBeanDefinitionNames();
        for(String name:names){
            System.out.println("name="+name);
        }

       StudentService service = (StudentService)context.getBean("studentServiceImpl");

        StudentBean student = new StudentBean();
        String name = UUID.randomUUID().toString().substring(0, 8);
        student.setName(name);
        student.setAge(119);
        service.addStudent(student);
    }
}
